#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>
#include <QRect>
#include <QDebug>
#include <QPixmap>
#include <QLabel>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

}


//Widget::Widget(QWidget *parent)
//    : QWidget(parent)
//    , ui(new Ui::Widget)
//{
//    ui->setupUi(this);

//    ui->pushButton_yes->setToolTip("这是yes按钮");
//    ui->pushButton_yes->setToolTipDuration(3000);

//    ui->pushButton_no->setToolTip("这是no按钮");
//    ui->pushButton_no->setToolTipDuration(10000);
//}

Widget::~Widget()
{
    delete ui;
}

//Widget::Widget(QWidget *parent)
//    : QWidget(parent)
//    , ui(new Ui::Widget)
//{
//    ui->setupUi(this);
//    QLabel *label = new QLabel("这是一段文字",this);

//    QFont font;
//    font.setBold(true);
//    font.setFamily("宋体");
//    font.setPointSize(20);
//    font.setUnderline(true);
//    font.setItalic(true);

//    label->setFont(font);   //把字体设置到label对象上
//}

//Widget::Widget(QWidget *parent)
//    : QWidget(parent)
//    , ui(new Ui::Widget)
//{
//    ui->setupUi(this);
//    QPushButton * button = new QPushButton("这是一个按钮",this);
//    button->move(200,200);

//    // 创建⼀个位图对象, 加载⾃定义光标图⽚
//    QPixmap pixmap(":/image/rocket.png");

//    pixmap = pixmap.scaled(50,50);  // 调整图⽚尺⼨

//    //创建 QCursor 对象, 并指定 "热点" 的坐标位置.
//    // 所谓 "热点" 就是⿏标点击时⽣效的位置
//    //以图片左上角为(0,0)，找到(30,30)作为光标真正点击的位置
//    QCursor cursor(pixmap,30,30);

//    button->setCursor(cursor);
//}

//Widget::~Widget()
//{
//    delete ui;
//}


//Widget::Widget(QWidget *parent)
//    : QWidget(parent)
//    , ui(new Ui::Widget)
//{
//    ui->setupUi(this);
////    this->setWindowTitle("这是一个窗口");

////使用正向斜杠 /
////    QIcon icon("D:/A_Book/watermelon.png");

////    QIcon icon(":/image/watermelon.png");
////    this->setWindowIcon(icon);
//}

//Widget::~Widget()
//{
//    delete ui;
//}

//void Widget::on_pushButton_clicked()
//{
//    QRect rect1 = ui->pushButton->geometry();
//    QRect rect2 = ui->pushButton->frameGeometry();

//    qDebug() << rect1;
//    qDebug() << rect2;
//}

//void Widget::on_pushButton_up_clicked()
//{
//    QRect rect = ui->pushButton_target->geometry(); //获取
//    rect.setY(rect.y()-5);  //仅仅移动y坐标
//    ui->pushButton_target->setGeometry(rect); //设置
//}

//void Widget::on_pushButton_down_clicked()
//{
//    QRect rect = ui->pushButton_target->geometry();
//    rect.setY(rect.y()+5);  //仅仅移动y坐标
//    ui->pushButton_target->setGeometry(rect);
//}

//void Widget::on_pushButton_left_clicked()
//{
//    QRect rect = ui->pushButton_target->geometry();
//    //整体移动
//    ui->pushButton_target->setGeometry(rect.x()-5,rect.y(),rect.width(),rect.height());
//}

//void Widget::on_pushButton_right_clicked()
//{
//    QRect rect = ui->pushButton_target->geometry();
//    ui->pushButton_target->setGeometry(rect.x() + 5,rect.y(),rect.width(),rect.height());
//}



//void Widget::on_pushButton_no_clicked()
//{
//    if(ui->pushButton->isEnabled())
//        ui->pushButton->setEnabled(false);
//}

//void Widget::on_pushButton_yes_clicked()
//{
//    if(false == ui->pushButton->isEnabled())
//        ui->pushButton->setEnabled(true);
//}



//void Widget::on_pushButton_clicked()
//{
//    ui->label->setText("毕业年薪3ow");
//}

//void Widget::on_pushButton_2_clicked()
//{
//    int w = this->geometry().width();
//    int h = this->geometry().height();
//    int x = rand() % w;
//    int y = rand() % h;
//    QRect rect = ui->pushButton_2->geometry();
//    ui->pushButton_2->setGeometry(x,y,rect.width(),rect.height());
//}

//void Widget::on_pushButton_2_pressed()
//{
//    int w = this->geometry().width();
//    int h = this->geometry().height();
//    int x = rand() % w;
//    int y = rand() % h;
//    QRect rect = ui->pushButton_2->geometry();
//    ui->pushButton_2->setGeometry(x,y,rect.width(),rect.height());
//}


//void Widget::on_pushButton_add_clicked()
//{
//    //获取窗口的不透明度
//    float opacity = this->windowOpacity();
//    if(opacity >= 1.0)
//        return;
//    qDebug() << opacity;
//    opacity += 0.1;
//    this->setWindowOpacity(opacity);
//}

//void Widget::on_pushButton_sub_clicked()
//{
//    //获取窗口的不透明度
//    float opacity = this->windowOpacity();
//    if(opacity <= 0.0)
//        return;
//    qDebug() << opacity;
//    opacity -= 0.1;
//    this->setWindowOpacity(opacity);
//}

void Widget::on_pushButton_light_clicked()
{
    this->setStyleSheet("background-color:240,240,240;");
    ui->textEdit->setStyleSheet("background-color:white; color:dark;");
    ui->pushButton_dark->setStyleSheet("color:dark;");
    ui->pushButton_light->setStyleSheet("color:dark;");
}

void Widget::on_pushButton_dark_clicked()
{
    this->setStyleSheet("background-color:#000;");
    ui->textEdit->setStyleSheet("background-color:#333; color:white;");
    ui->pushButton_dark->setStyleSheet("color:white;");
    ui->pushButton_light->setStyleSheet("color:white;");
}
